<template>
  <div>
    <a-modal
        :bodyStyle="{'height':350+'px'}"
        v-model="showImportModal"
        :closable="false"
        :footer="null"
        :width="800"
        :destroyOnClose="true"
        :title="importTitle"
        v-if="mHref"
    >
      <mImport @modalClose="importClose" :mUrl="submitUrl" :mHref="mHref" :assetType="assetType" :enterpriseType="enterpriseType"/>
    </a-modal>
  </div>
</template>

<script>
import mImport from './importCommonComponent'

export default {
  components: {
    mImport
  },
  name: "importCommonPage",
  props: {
    assetType: String,//资产的导入，需要用到资产typeId
    enterpriseType: String,// type   企业类型 1、企业 2、维修点 3、年检点
    importUrl: String,
    title: String
  },
  data() {
    return {
      fileList: [],
      mHref: null,
      importTitle: '',
      showImportModal: false,
      submitUrl: this.importUrl
    }
  },
  mounted() {
    this.init();
  },
  methods: {
    init(){
      console.log(88, this.importUrl, this.assetType,this.enterpriseType)
      switch (this.importUrl) {
        case 'batchImportRoute':
          this.mHref = '/client/downloadFile?fileName=route_import_template.xlsx&saveName=route_import_template.xlsx&fileType=7';
          this.importTitle = '导入路线';
          break;
        case 'batchImportRouteLocation':
          this.mHref = '/client/downloadFile?fileName=route_location_import_template.xlsx&saveName=route_location_import_template.xlsx&fileType=7';
          this.importTitle = '导入路线坐标';
          break;
        case 'batchImportSectionLocation':
          this.mHref = '/client/downloadFile?fileName=section_location_import_template.xlsx&saveName=section_location_import_template.xlsx&fileType=7';
          this.importTitle = '导入路段坐标';
          break;
        case 'batchImportSection':
          this.mHref = '/client/downloadFile?fileName=section_import_template.xlsx&saveName=section_import_template.xlsx&fileType=7';
          this.importTitle = '导入路段';
          break;
        case 'batchImportRfid':
          this.mHref = '/client/downloadFile?fileName=rfid_import_template.xlsx&saveName=rfid_import_template.xlsx&fileType=7';
          this.importTitle = '导入标签';
          break;
        case 'batchImportRouteMonitor':
          this.mHref = '/client/downloadFile?fileName=route_monitor_import_template.xlsx&saveName=route_monitor_import_template.xlsx&fileType=7';
          this.importTitle = '导入资产状态监控';
          break;
        case 'batchImportRouteUser':
          this.mHref = '/client/downloadFile?fileName=route_user_import_template.xlsx&saveName=route_user_import_template.xlsx&fileType=7';
          this.importTitle = '导入路长';
          break;
        case 'batchImportSafeMonitor':
          this.mHref = '/client/downloadFile?fileName=safe_monitor_import_template.xlsx&saveName=safe_monitor_import_template.xlsx&fileType=7';
          this.importTitle = '导入安全监控';
          break;
        case 'batchImportSupervise'://不做
          this.mHref = '/client/downloadFile?fileName=route_import_template.xlsx&saveName=route_import_template.xlsx&fileType=7';
          this.importTitle = '导入路政巡查记录';
          break;
        case 'batchImportVillages':
          this.mHref = '/client/downloadFile?fileName=villages_import_template.xlsx&saveName=villages_import_template.xlsx&fileType=7';
          this.importTitle = '导入村镇';
          break;
        case 'batchImportProduct':
          this.mHref = '/client/downloadFile?fileName=product_import_template.xlsx&saveName=product_import_template.xlsx&fileType=7';
          this.importTitle = '导入特产';
          break;
        case 'batchImportTopic':
          this.mHref = '/client/downloadFile?fileName=topic_import_template.xlsx&saveName=topic_import_template.xlsx&fileType=7';
          this.importTitle = '导入专题';
          break;
        case 'batchImportCheckpoint'://不做
          this.mHref = '/client/downloadFile?fileName=route_import_template.xlsx&saveName=route_import_template.xlsx&fileType=7';
          this.importTitle = '导入防疫站点';
          break;
        case 'batchImportEmergencyDevice'://
          this.mHref = '/client/downloadFile?fileName=emergency_device_import_template.xlsx&saveName=emergency_device_import_template.xlsx&fileType=7';
          this.importTitle = '导入应急设备';
          break;
        case 'batchImportEmergencyMaterial':
          this.mHref = '/client/downloadFile?fileName=emergency_material_import_template.xlsx&saveName=emergency_material_import_template.xlsx&fileType=7';
          this.importTitle = '导入应急物资';
          break;
        case 'batchImportEmergencyPoint'://
          this.mHref = '/client/downloadFile?fileName=emergency_point_import_template.xlsx&saveName=emergency_point_import_template.xlsx&fileType=7';
          this.importTitle = '导入应急点位';
          break;
        case 'batchImportMaintainProject':
          this.mHref = '/client/downloadFile?fileName=maintain_project_import_template.xlsx&saveName=maintain_project_import_template.xlsx&fileType=7';
          this.importTitle = '导入项目';
          break;
        case 'batchImportPatrol'://
          this.mHref = '/client/downloadFile?fileName=patrol_import_template.xlsx&saveName=patrol_import_template.xlsx&fileType=7';
          this.importTitle = '导入巡查记录';
          break;

        case 'batchImportRoadPlanProject'://
          this.mHref = '/client/downloadFile?fileName=road_plan_project_import_template.xlsx&saveName=road_plan_project_import_template.xlsx&fileType=7';
          this.importTitle = '导入项目';
          break;

        case 'batchImportQuestion':
          this.mHref = '/client/downloadFile?fileName=question_import_template.xlsx&saveName=question_import_template.xlsx&fileType=7';
          this.importTitle = '导入试题';
          break;

        case 'batchImportReshuffle'://做过,和其他不一样，需要路线路段等参数
          this.importTitle = '导入异动';
          break;

        case 'batchImportPilot'://运政管理——司机导入
          this.mHref = '/client/downloadFile?fileName=pilot_import_template.xlsx&saveName=pilot_import_template.xlsx&fileType=7';
          this.importTitle = '运政管理-导入司机';
          break;

        case 'batchImportEnterprise'://运政管理——企业、维修点、年检点导入
          this.mHref = '/client/downloadFile?fileName=enterprise_import_template.xlsx&saveName=enterprise_import_template.xlsx&fileType=7';
          switch (parseInt(this.enterpriseType)) {
            case 1:
              this.importTitle = '运政管理-导入企业';
              break;
            case 2:
              this.importTitle = '运政管理-导入维修点';
              break;
            case 3:
              this.importTitle = '运政管理-导入年检点';
              break;
          }
          break;

        case 'asset':
          switch (parseInt(this.assetType)) {
            case 8:
            case 16:
            case 17:
            case 18:
            case 19:
            case 20:
            case 21:
            case 36://交通标志
              this.mHref = '/client/downloadFile?fileName=traffic_sign_import_template.xlsx&saveName=traffic_sign_import_template.xlsx&fileType=7';
              this.importTitle = '导入交通标志';
              this.submitUrl = 'batchImportTrafficSign';
              break;
            case 9://文化石
              this.mHref = '/client/downloadFile?fileName=culture_stone_import_template.xlsx&saveName=culture_stone_import_template.xlsx&fileType=7';
              this.importTitle = '导入文化石';
              this.submitUrl = 'batchImportCultureStone';
              break;
            case 10:
              this.mHref = '/client/downloadFile?fileName=patrol_import_template.xlsx&saveName=patrol_import_template.xlsx&fileType=7';
              this.importTitle = '导入巡查记录';
              break;
            case 11://桥
              this.mHref = '/client/downloadFile?fileName=bridge_import_template.xlsx&saveName=bridge_import_template.xlsx&fileType=7';
              this.importTitle = '导入桥梁';
              this.submitUrl = 'batchImportBridge';
              break;
            case 12://交调设备
              this.mHref = '/client/downloadFile?fileName=inter_equipment_import_template.xlsx&saveName=inter_equipment_import_template.xlsx&fileType=7';
              this.importTitle = '导入交调设备';
              this.submitUrl = 'batchImportInterEquipment';
              break;
            case 13://视频监控
              this.mHref = '/client/downloadFile?fileName=video_monitor_import_template.xlsx&saveName=video_monitor_import_template.xlsx&fileType=7';
              this.importTitle = '导入视频监控';
              this.submitUrl = 'batchImportVideoMonitor';
              break;
            case 14://可变情报板
              this.mHref = '/client/downloadFile?fileName=vms_import_template.xlsx&saveName=vms_import_template.xlsx&fileType=7';
              this.importTitle = '导入可变情报板';
              this.submitUrl = 'batchImportVms';
              break;
            case 15:
            case 27:
            case 35://气象设施、照明设施、交通量观测站
              this.mHref = '/client/downloadFile?fileName=observe_import_template.xlsx&saveName=observe_import_template.xlsx&fileType=7';
              this.importTitle = '导入数据';
              this.submitUrl = 'batchImportObserve';
              break;
            case 22://公交站台
              this.mHref = '/client/downloadFile?fileName=station_import_template.xlsx&saveName=station_import_template.xlsx&fileType=7';
              this.importTitle = '导入公交站台';
              this.submitUrl = 'batchImportStation';
              break;
            case 23://隧道
              this.mHref = '/client/downloadFile?fileName=tunnel_import_template.xlsx&saveName=tunnel_import_template.xlsx&fileType=7';
              this.importTitle = '导入隧道';
              this.submitUrl = 'batchImportTunnel';
              break;
            case 24://涵洞
              this.mHref = '/client/downloadFile?fileName=culvert_import_template.xlsx&saveName=culvert_import_template.xlsx&fileType=7';
              this.importTitle = '导入涵洞';
              this.submitUrl = 'batchImportCulvert';
              break;
            case 25://互通
              this.mHref = '/client/downloadFile?fileName=interflow_import_template.xlsx&saveName=interflow_import_template.xlsx&fileType=7';
              this.importTitle = '导入互通';
              this.submitUrl = 'batchImportInterflow';
              break;
            case 26://通道
              this.mHref = '/client/downloadFile?fileName=passageway_import_template.xlsx&saveName=passageway_import_template.xlsx&fileType=7';
              this.importTitle = '导入通道';
              this.submitUrl = 'batchImportPassageway';
              break;
            case 28:
            case 29:
            case 30:
            case 31://超限检测站、收费站、服务区、交通运输执法机构
              this.mHref = '/client/downloadFile?fileName=service_import_template.xlsx&saveName=service_import_template.xlsx&fileType=7';
              this.importTitle = '导入数据';
              this.submitUrl = 'batchImportService';
              break;
            case 32://隔音墙
              this.mHref = '/client/downloadFile?fileName=acoustic_import_template.xlsx&saveName=acoustic_import_template.xlsx&fileType=7';
              this.importTitle = '导入隔音墙';
              this.submitUrl = 'batchImportAcoustic';
              break;
            case 33://非公路标志
              this.mHref = '/client/downloadFile?fileName=other_sign_import_template.xlsx&saveName=other_sign_import_template.xlsx&fileType=7';
              this.importTitle = '导入非公路标志';
              this.submitUrl = 'batchImportOtherSign';
              break;
            case 34://绿化带
              this.mHref = '/client/downloadFile?fileName=green_belt_import_template.xlsx&saveName=green_belt_import_template.xlsx&fileType=7';
              this.importTitle = '导入绿化带';
              this.submitUrl = 'batchImportGreenBelt';
              break;
            case 37://公路护栏
              this.mHref = '/client/downloadFile?fileName=guardrail_import_template.xlsx&saveName=guardrail_import_template.xlsx&fileType=7';
              this.importTitle = '导入公路护栏';
              this.submitUrl = 'batchImportGuardrail';
              break;
          }

          break;
        case 'batchImportBayonet'://导入卡口
          this.mHref = '/client/downloadFile?fileName=bayonet_import_template.xlsx&saveName=bayonet_import_template.xlsx&fileType=7';
          this.importTitle = '导入卡口';
          break;
        case 'batchImportParticipants':
          this.mHref = '/client/downloadFile?fileName=participants_import_template.xlsx&saveName=participants_import_template.xlsx&fileType=7';
          this.importTitle = '参会人员';
          break;
        case 'batchImportFeedWorksheet':
          this.mHref = '/client/downloadFile?fileName=feed_worksheet_import_template.xlsx&saveName=feed_worksheet_import_template.xlsx&fileType=7';
          this.importTitle = '导入反馈工单';
          break;
        case 'batchImportEngineProject':
          this.mHref = '/client/downloadFile?fileName=engine_project_import_template.xlsx&saveName=engine_project_import_template.xlsx&fileType=7';
          this.importTitle = '导入工程项目';
          break;
        case 'batchImportInspect':
          this.mHref = '/client/downloadFile?fileName=inspect_import_template.xlsx&saveName=inspect_import_template.xlsx&fileType=7';
          this.importTitle = '导入巡查数据';
          break;
        case 'batchImportContract':
          this.mHref = '/client/downloadFile?fileName=contract_import_template.xlsx&saveName=contract_import_template.xlsx&fileType=7';
          this.importTitle = '导入合同数据';
          break;
        case 'batchImportCompany':
          this.mHref = '/client/downloadFile?fileName=company_import_template.xlsx&saveName=company_import_template.xlsx&fileType=7';
          this.importTitle = '导入养护单位数据';
          break;
      }
    },
    showImport() {
      console.log(3444, this.enterpriseType, this.importUrl, this.mHref)
      this.showImportModal = true;
    },
    importClose(params) {//导入功能的关闭
      console.log(289,params)
      if (params && params.refresh) {
        this.$util.eventBus.$emit(this.$util.notifyKey.importRefreshMessage);
      }
      this.showImportModal = false;
    },
  }
}
</script>

<style scoped>
</style>
